#ifndef SPIDISPLAY_HPP
#define SPIDISPLAY_HPP

#include "driver/spi_master.h"
#include "driver/gpio.h"

/* 引脚定义 */
#define SPI_MOSI_GPIO_PIN   GPIO_NUM_11         /* SPI2_MOSI */
#define SPI_CLK_GPIO_PIN    GPIO_NUM_12         /* SPI2_CLK */
#define SPI_MISO_GPIO_PIN   GPIO_NUM_13  
#define LCD_NUM_CS      GPIO_NUM_39

class SPI {
public:
    SPI();
    SPI(spi_host_device_t host, int sckPin, int mosiPin, int misoPin);
    ~SPI();
    void init() const;
    static void spiWriteCmd(spi_device_handle_t handle, uint8_t cmd);
    void spiWriteData(spi_device_handle_t handle, const uint8_t *data, int len);
    

private:
    spi_host_device_t _host;
    int _sckPin{};
    int _mosiPin{};
    int _misoPin{};
    spi_device_handle_t _spi{};
};

#endif // SPIDISPLAY_HPP